const ologin = document.querySelector(".login")
const owelcome = document.querySelector(".welcome")
const oun = document.querySelector(".un")
const oexit = document.querySelector(".exit")
const ogoCart = document.querySelector(".goCart")
const ogoCart2 = document.querySelector(".goCart2")

// console.log(ogoCart)


// 读取登录信息
if(localStorage.getItem("isLogin") === "ok"){
    console.log(1010)
    ologin.style.display = "none";
    owelcome.style.display = "inline-block";
    oun.innerHTML = localStorage.getItem("username");
}else{
    ologin.style.display = "inline-block";
    owelcome.style.display = "none";
    oun.innerHTML = "xxx";
}

oexit.onclick = function(){
    localStorage.removeItem("username");
    localStorage.setItem("isLogin", "");
    ologin.style.display = "inline-block";
    owelcome.style.display = "none";
    oun.innerHTML = "xxx";
}

ogoCart.onclick = function(){
    console.log("ok")
    if(localStorage.getItem("isLogin") === "ok"){
        location.href = "./cart.html"
    }else{
        alert("未登录状态，不允许打开购物车，请先登录")
        location.href = "./login.html"
    }
}

ogoCart2.onclick = function(){
    console.log("ok")
    if(localStorage.getItem("isLogin") === "ok"){
        location.href = "./cart.html"
    }else{
        alert("未登录状态，不允许打开购物车，请先登录")
        location.href = "./login.html"
    }
}